package cn.newtouch.controller;

import cn.newtouch.fallBack.UserBack;
import cn.newtouch.feign.UserFeignService;
import cn.newtouch.domain.User;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderContorller {

    @Autowired
    private UserFeignService userFeignService;

    @GetMapping("/getById/{id}")
    @SentinelResource(value = "user-getById",fallback = "UserFallBack",fallbackClass = UserBack.class)
    public User getById(@PathVariable("id") Long id){
        return userFeignService.getById(id);
    }

  /* public User UserFallBack(@PathVariable("id") Long id,Throwable e){
        e.printStackTrace();
        return new User(-1L,"触发熔断","熔断咯。。。。。");
    }*/


}
